package com.cn.xc.utils;

import com.cn.exception.MyException;

/**
 * FUN: reflect tools class
 * 
 * @author sushy
 * @date 2016-3-24
 */
public class ReflectUtil {

	/**
	 *  //# instance obj
	 * @param className
	 */
	public static final Object newInstance(String className) {
		return newInstance(findClass(className));
	}

	/**
	 *  //# instance obj
	 * @param aClass
	 */
	public static final Object newInstance(Class<?> aClass) {
		try {
			return aClass.newInstance();
		} catch (InstantiationException e) {
			
			throw new MyException("", e, "className", aClass.getName());
		} catch (IllegalAccessException e) {
			
			throw new MyException("", e, "className", aClass.getName());
		}
	}

	public static final Class<?> findClass(String className) {
		try {
			return Class.forName(className.trim());
		} catch (ClassNotFoundException e) {
			
			throw new MyException("", e, "className", className);
		}
	}

}
